﻿    <div class="fitem_auto padding_H" id="Root">
        <div v-show="msg" class="msgbox_alert">{{msg}}</div>
        <div v-show="active">
            <buttonlist :hook="hooks[0]" :set="sets[0]" class="wyjcontainer_H border_B padding_V"></buttonlist>
            <pagenation :hook="hooks[1]" :set="table" :api="Api" hasToolbar="yes">
                <template #toolbar="postData">
                    <input placeholder="请输入产品名称" v-model="postData.queryKeys.key" />
                </template>
                <template #td="models">
                    <td><a class="tooltip" @@click="Switch(3, models.model)">{{models.model.Production.Name}}<span class="tooltiptext">查看详情</span></a></td>
                    <td>{{models.model.PlanAmount}}</td>
                    <td>{{models.model.Amount}}</td>
                    <td>{{models.model.Date.substring(0,10)}}</td>
                    <td>{{models.model.Finished?'是':'否'}}</td>
                    <td>
                        <a v-for="(btn,i) in icons" :key="i" :class="btn.class" @@click="btn.act(models.model)"><i :class="btn.icon"></i></a>
                    </td>
                </template>
            </pagenation>
        </div>
        <div v-show="!active" class="exclusive wyjcontainer_V">
            <buttonlist :hook="hooks[2]" :set="sets[1]"  class="wyjcontainer_HL border_B padding_V"></buttonlist>
            <editor :hook="hooks[3]" :set="labels">
                <template v-if="viewMode" #ele>
                    <div class="formGroup_ele" v-for="(y,x) in labels" :key="x">{{model[x].Name || model[x]}}</div>
                </template>
                <template v-else #ele="slotProps">
                    <select class="formGroup_ele" v-model="model.Production">
                        <option value="">请选择产品</option>
                        @{
                            var Productions = WYJWeb.Models.BaseInfo.Production.GetAll();
                            foreach (var Production in Productions)
                            {
                                <option value="@Production.Key">@Production.Value.Name</option>
                            }
                        }
                    </select>
                    <input class="formGroup_ele" v-model="model.PlanAmount" placeholder="请输入计划出库数量" />
                    <input class="formGroup_ele" v-model="model.Date" placeholder="请选择计划出库时间" type="date"/>

                </template>
                <template #subtmpl></template>
            </editor>
            <buttonlist :hook="hooks[4]" :set="sets[2]" class="wyjcontainer_HM padding_V border_T"></buttonlist>
        </div>
    </div>

@section foot {
    <script type="text/javascript">
        var app = new App({
            Api: 'OutStockPlan',
            table: {
                titles: ["产品名称", "计划出库数量", "已出库数量", "计划出库时间", "是否完成", "操作"],
            },
            PageTitles: ['出库计划', '', '', ''],
            icons: [{
                icon:'fa fa-trash',
                act: (e, i) => {
                    app.DeleteById(e.Id, i)
                }
            }],
            labels: {
                Production: '产品名称',
                PlanAmount: '计划出库数量',
                Date: '计划出库时间',
            },
        });
        app.BeforeSave = function (model) {
            model.Production = { Id: model.Production };
            model.StockSpace = { Id: model.StockSpace };
            console.log(model);
            return model;
        };
    </script>
}